//
//  ViewController.m
//  test
//
//  Created by Vincent on 2017/3/25.
//  Copyright © 2017年 Vincent. All rights reserved.
//

#import "ViewController.h"
#import "ZLLCurveView.h"


#define kViewW self.view.bounds.size.width
#define kViewH self.view.bounds.size.height

@interface ZLLView : UIView

@property(nonatomic,strong)ZLLCurveView *curveV;


@end

@implementation ZLLView

-(id)init{
    self = [super init];
    if(self){
        _curveV = [ZLLCurveView new];
        _curveV.backgroundColor = [UIColor clearColor];
        [self addSubview:_curveV];
    
    }
    
    return self;
}

@end



@interface ViewController ()<CALayerDelegate>

@property(nonatomic,strong)ZLLView *tmV;


@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    self.tmV = [ZLLView new];
    self.tmV.frame = CGRectMake(0,100,kViewW, 300);
    self.tmV.backgroundColor = [UIColor orangeColor];
    
    [self.view addSubview:self.tmV];
}


-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    
    NSMutableArray *arr = [NSMutableArray new];
    NSMutableArray *xarr = [NSMutableArray new];
    for(int i=0;i<50;i++){
        
        float yval = arc4random()%101;
        ZLLCurveModel *model = [ZLLCurveModel curveModelWithYvalue:yval yDescription:[[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%.0f",yval] attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12],NSForegroundColorAttributeName:[UIColor greenColor]}]];
        
        [arr addObject:model];
        
        [xarr addObject:[[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%d",i] attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12],NSForegroundColorAttributeName:[UIColor greenColor]}]];
        
    }
    
    NSMutableArray *arr2 = [NSMutableArray new];
    for(int i=0;i<50;i++){
        
        float yval = arc4random()%101;
        ZLLCurveModel *model = [ZLLCurveModel curveModelWithYvalue:yval yDescription:[[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%.0f",yval] attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12],NSForegroundColorAttributeName:[UIColor greenColor]}]];
        
        [arr2 addObject:model];
        
    }
    
    self.tmV.curveV.xDescriptions = xarr;
    self.tmV.curveV.frame = CGRectMake(0, 0,kViewW, 200);
    self.tmV.curveV.curveColors = @[[UIColor greenColor],[UIColor blueColor]];
    self.tmV.curveV.curveArr = @[arr,arr2];
    self.tmV.curveV.components.xDensity = 100;

    [self.tmV.curveV drawCurve];
    
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
